<template>
  <div>
  <basic-container-one>
    <vue-element-loading :active="isActive" spinner="bar-fade-scale" color="#409eff" background-color="rgba(255,255,255,0.2)"/>
    <el-form :inline="true">
      <div style="margin-top: 22px">
        <el-form-item>
          <el-select v-model="formInline.gameFlName" filterable clearable placeholder="游戏大类目">
            <el-option
              v-for="item in gameFllist"
              :key="item.gameName"
              :label="item.gameName"
              :value="item.gameName"/>
          </el-select>
        </el-form-item>
        <el-form-item>
          <!--<el-input clearable v-model="formInline.gameName" placeholder="游戏名称"/>-->
          <el-select v-model="formInline.gameName" filterable clearable placeholder="游戏名称">
            <el-option
              v-for="item in gamelist"
              :key="item.gameName"
              :label="item.gameName"
              :value="item.gameName"/>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.userAccount" placeholder="玩家账号"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.orderNum" placeholder="游戏订单号"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.payOrder" placeholder="商户订单号"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.promoteName" placeholder="推广员"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.platformName" placeholder="平台名称"/>
        </el-form-item>
        <el-form-item>
          <el-select v-model=" formInline.payWay " clearable placeholder="支付方式">
            <el-option label="微信" value="WX_NATIVE"></el-option>
            <el-option label="支付宝" value="ALI_PC"></el-option>
            <el-option label="淘宝" value="TB"></el-option>
            <el-option label="支付宝（私）" value="TB-P"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model=" formInline.bizType " clearable placeholder="业务类型">
            <el-option label="自动代充" value="1"></el-option>
            <el-option label="上号代充" value="2"></el-option>
            <el-option label="平台代充" value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model="formInline.isFirstPay" clearable placeholder="充值类型">
            <el-option label="首充" value="1"></el-option>
            <el-option label="续充" value="2"></el-option>
            <el-option label="内充" value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model=" formInline.isReplenishment " clearable placeholder="是否补单">
            <el-option label="否" value="0"></el-option>
            <el-option label="是" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model=" formInline.isPayCurrency " clearable placeholder="是否已打币">
            <el-option label="否" value="0"></el-option>
            <el-option label="是" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model=" formInline.isRefund " clearable placeholder="是否退款">
            <el-option label="否" value="1"></el-option>
            <el-option label="是" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.collectionAccount" placeholder="收款账户"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.program" placeholder="项目群"/>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="formInline.department" placeholder="部门"/>
        </el-form-item>
          <el-form-item>
            <el-date-picker
              v-model="time"
              clearable
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :default-time="['00:00:00', '23:59:59']"
              :picker-options="pickerOptions">
            </el-date-picker>
          </el-form-item>
        <el-form-item>
          <el-date-picker
            v-model="timeDb"
            clearable
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="打币开始日期"
            end-placeholder="打币结束日期"
            :default-time="['00:00:00', '23:59:59']"
            :picker-options="pickerOptions">
          </el-date-picker>
        </el-form-item>

          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="onSubmit">查询</el-button>
            <el-button icon="el-icon-download" type="primary" @click="handleExport"   >下载</el-button>
            <el-button icon="el-icon" type="primary" @click="editPromote"   >批量修改推广员</el-button>
          </el-form-item>
          <el-form-item>
            <el-popover placement="bottom" title="筛选列" trigger="click" width="40">
              <el-checkbox-group
                v-model="checkedColumns"
                class="checkbox-wrap"
              >
                <el-checkbox size="large"  style="display: block" v-for="item in checkBoxGroup" :key="item" :label="item" :value="item"></el-checkbox>
              </el-checkbox-group>
              <div title="筛选列" slot="reference"><el-button type="primary">筛选列</el-button></div>
            </el-popover>
          </el-form-item>
      </div>
    </el-form>
  </basic-container-one>
    <basic-container>

    <el-row>
      <el-col :span="24">
        <template>
          <el-table
            :data="tableData"
            stripe
            :summary-method="getSumDeposit"
            show-summary
            style="width: 100%">
            <el-table-column
              prop="gameName"
              label="游戏" key="4">
            </el-table-column>
            <el-table-column
              prop="payTime"
              label="付款时间">
              <template slot-scope="scope">
                <span v-if="scope.row.payTime!=''"><span
                  class="skucost-pruice">{{ scope.row.payTime  | formatDate('YYYY-MM-DD HH:mm:ss') }}</span></span>
              </template>
            </el-table-column>
            <el-table-column
              prop="userAccount"
              label="玩家账号" key="1">
            </el-table-column>
            <el-table-column
              prop="payAmount"
              label="金额">
              <template slot-scope="scope">
                <span
                  class="skucost-pruice">{{ (Number(scope.row.payAmount)/100).toFixed(2) }}</span>
              </template>
            </el-table-column>
            <el-table-column
              prop="firstTime"
              label="充值方式">
              <template slot-scope="scope">
                <span v-if="scope.row.payWay=='ALI_PC'"><span class="skucost-pruice">支付宝</span></span>
                <span v-if="scope.row.payWay=='WX_NATIVE'"><span class="skucost-pruice">微信</span></span>
                <span v-if="scope.row.payWay=='SCANPAY_ALIPAY'"><span class="skucost-pruice">支付宝</span></span>
                <span v-if="scope.row.payWay=='SCANPAY_WEIXIN'"><span class="skucost-pruice">微信</span></span>
                <span v-if="scope.row.payWay=='TB'"><span class="skucost-pruice">淘宝</span></span>
                <span v-if="scope.row.payWay=='TB-P'"><span class="skucost-pruice">支付宝(私)</span></span>
                <span v-if="scope.row.payWay=='BANK'"><span class="skucost-pruice">银行卡</span></span>
                <span v-if="scope.row.payWay=='WX-P'"><span class="skucost-pruice">微信(私)</span></span>
                <span v-if="scope.row.payWay=='TB-ZC'"><span class="skucost-pruice">对公(直充)</span></span>
              </template>
            </el-table-column>
            <el-table-column
              prop="collectionAccount"
              label="收款账号">
            </el-table-column>

            <el-table-column
              prop="isFirstPay"
              label="充值类型">
              <template slot-scope="scope">
                <span v-if="scope.row.isFirstPay==1"><span class="skucost-pruice">首充</span></span>
                <span v-if="scope.row.isFirstPay==2"><span class="skucost-pruice">续充</span></span>
                <span v-if="scope.row.isFirstPay==3"><span class="skucost-pruice">内充</span></span>
              </template>
            </el-table-column>

            <el-table-column
              prop="discount"
              label="折扣">
              <template slot-scope="scope">
                <span v-if="scope.row.discount>0" class="skucost-pruice">{{scope.row.discount}}%</span>
                <span v-if="scope.row.discount<=0" class="skucost-pruice"></span>
              </template>
            </el-table-column>
            <el-table-column
              prop="platformCurrency"
              label="平台币">
              <template slot-scope="scope">
                <span v-if="scope.row.platformCurrency>0" class="skucost-pruice">{{scope.row.platformCurrency}}</span>
                <span v-if="scope.row.platformCurrency<=0" class="skucost-pruice"></span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="colData[0].istrue"
              prop="platformCurrencyTime"
              label="打币时间">
              <template slot-scope="scope">
                <span v-if="scope.row.platformCurrencyTime!=''"><span
                  class="skucost-pruice">{{ scope.row.platformCurrencyTime  | formatDate('YYYY-MM-DD HH:mm:ss') }}</span></span>
                <span v-if="scope.row.platformCurrencyTime==''"><span
                  class="skucost-pruice"></span></span>
              </template>
            </el-table-column>

            <el-table-column
              prop="welfareGift"
              label="福利赠送">
              <template slot-scope="scope">
                 <span v-if="scope.row.welfareGift > 0"
                   class="skucost-pruice">{{ scope.row.welfareGift }}</span>
              </template>
            </el-table-column>

            <el-table-column
              prop="welfareGift"
              label="拨币总数">
              <template slot-scope="scope">
                 <span v-if="scope.row.welfareGift > 0 && scope.row.platformCurrency > 0"
                       class="skucost-pruice">{{ (Number(scope.row.welfareGift)+ Number(scope.row.platformCurrency))}}</span>
                <span v-if="scope.row.welfareGift <= 0 && scope.row.platformCurrency > 0"
                      class="skucost-pruice">{{ (Number(scope.row.platformCurrency))}}</span>
                <span v-if="scope.row.welfareGift > 0 && scope.row.platformCurrency <= 0"
                      class="skucost-pruice">{{ (Number(scope.row.welfareGift))}}</span>
              </template>
            </el-table-column>

            <el-table-column
              prop="bizType"
              label="业务类型">
              <template slot-scope="scope">
                <span v-if="scope.row.bizType==1"><span class="skucost-pruice">自动代充</span></span>
                <span v-if="scope.row.bizType==2"><span class="skucost-pruice">上号代充</span></span>
                <span v-if="scope.row.bizType==3"><span class="skucost-pruice">平台代充</span></span>
              </template>
            </el-table-column>

            <el-table-column
              v-if="colData[1].istrue"
              prop="platformName"
              label="平台名称">
            </el-table-column>

            <el-table-column
              v-if="colData[2].istrue"
              prop="playerWechat"
              label="玩家微信">
            </el-table-column>

            <el-table-column
              v-if="colData[3].istrue"
              prop="serverNum"
              label="区服">
            </el-table-column>

            <el-table-column
              v-if="colData[4].istrue"
              prop="program"
              label="项目群">
            </el-table-column>

            <el-table-column
              v-if="colData[5].istrue"
              prop="department"
              label="部门">
            </el-table-column>

            <el-table-column
              v-if="colData[6].istrue"
              prop="promoteName"
              label="推广员">
            </el-table-column>

            <el-table-column
              v-if="colData[7].istrue"
              prop="orderNum"
              label="游戏订单号" key="2">
            </el-table-column>
            <el-table-column
              v-if="colData[8].istrue"
              prop="payOrder"
              label="商户订单号">
            </el-table-column>

            <el-table-column
              v-if="colData[9].istrue"
              prop="isReplenishment"
              label="是否补单">
              <template slot-scope="scope">
                <span v-if="scope.row.isReplenishment==0"><span class="skucost-pruice">否</span></span>
                <span v-if="scope.row.isReplenishment==1"><span class="skucost-pruice" style="color: red">是</span></span>
              </template>
            </el-table-column>

            <el-table-column
              v-if="colData[10].istrue"
              prop="memo"
              label="备注">
            </el-table-column>

            <el-table-column
              v-if="colData[11].istrue"
              prop="isRefund"
              label="是否退款">
              <template slot-scope="scope">
                <span v-if="scope.row.isRefund==1"><span class="skucost-pruice">否</span></span>
                <span v-if="scope.row.isRefund==2"><span class="skucost-pruice" style="color: red">是</span></span>
              </template>
            </el-table-column>

            <el-table-column label="操作" v-if="this.isShowEdit">
              <template slot-scope="scope">
                  <el-button @click="recover(scope.row)"  type="text" size="medium">编辑</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-sizes="[10,20, 50, 100, 200]"
          :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total">
        </el-pagination>
      </el-col>
    </el-row>

  </basic-container>

    <el-dialog :title="mode" :visible.sync="dialogFormVisible" @close="closeDialog()" :close-on-click-modal="false" customClass="customViewUser1">
      <div v-if="dialogFormVisible">
        <el-form :model="form" label-width="100px" class="demo-ruleForm" ref="ruleForm">
          <!--<el-form-item label="游戏：">
            <el-input v-model="form.gameName" clearable placeholder="请输入游戏名称" maxlength='100' style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="收款账号：">
            <el-input v-model="form.collectionAccount" clearable placeholder="请输入收款账号" maxlength='100' style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="充值类型：">
            <el-select v-model="form.isFirstPayS" clearable placeholder="请选择充值类型"  style="width:100px">
              <el-option label="首冲" value="1" key="1"></el-option>
              <el-option label="续充" value="2" key="2"></el-option>
              <el-option label="内充" value="3" key="3"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="折扣：">
            <el-input v-model="form.discount" clearable placeholder="请输入折扣" style="width:70px;" oninput="value=value.replace(/[^\d]/g,'')" maxlength='3'></el-input>&nbsp;%
          </el-form-item>
          <el-form-item label="平台币：">
            <el-input v-model="form.platformCurrency" clearable placeholder="请输入平台币" style="width:350px" oninput="value=value.replace(/[^\d]/g,'')" maxlength='10'></el-input>
          </el-form-item>
          <el-form-item label="平台名称：">
            <el-input v-model="form.platformName" clearable placeholder="请输入平台名称" maxlength='50' style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="玩家微信：">
            <el-input v-model="form.playerWechat" clearable placeholder="请输入玩家微信" style="width:350px" maxlength='50'></el-input>
          </el-form-item>
          <el-form-item label="玩家区服：">
            <el-input v-model="form.serverNum" clearable placeholder="请输入玩家区服" style="width:350px" maxlength='50'></el-input>
          </el-form-item>
          <el-form-item label="项目群：">
            <el-input v-model="form.program" clearable placeholder="请输入项目群" maxlength='100' style="width:350px"></el-input>
          </el-form-item>-->
          <el-form-item label="金额：">
            {{(Number(form.payAmount)/100).toFixed(2)}}
          </el-form-item>
          <el-form-item label="部门：">
            <el-input v-model="form.department" clearable placeholder="请输入部门" clearable style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="推广员：">
            <el-input v-model="form.promoteName" clearable placeholder="请输入推广员" clearable style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="备注：">
            <el-input v-model="form.memo" clearable placeholder="请输入备注" type="textarea" :rows = "5" clearable style="width:350px"></el-input>
          </el-form-item>
          <!----
          <el-form-item label="充值方式：" v-if="isShowPayTime" >
            <el-select v-model="form.payWay" clearable placeholder="充值方式"  style="width:170px">
              <el-option label="淘宝" value="TB" key="TB"></el-option>
              <el-option label="支付宝(私)" value="TB-P" key="TB-P"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item v-if="isShowPayTime" label="付款时间：">
            <el-date-picker
              v-model="form.editPayTime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd HH:mm:ss"
              format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>-->
          <el-form-item label="打币时间：">
            <el-date-picker
              v-model="form.editPlatformCurrencyTime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd HH:mm:ss"
              format="yyyy-MM-dd HH:mm:ss">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="是否退款：">
            <el-select v-model="form.isRefundS" clearable placeholder="请选择是否退款"  style="width:150px">
              <el-option label="否" value="1" key="1"></el-option>
              <el-option label="是" value="2" key="2"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog()">取 消</el-button>
        <el-button type="primary" @click="suer()">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="mode" :visible.sync="dialogEditFormVisible" @close="closeEditDialog()" :close-on-click-modal="false" customClass="customViewUser1">
      <div v-if="dialogEditFormVisible">
        <el-form :model="editForm" :rules="rules" label-width="100px" class="demo-ruleForm" ref="ruleForm">
          <el-form-item label="账号：" prop="userAccount">
            <el-input v-model="editForm.userAccount" clearable placeholder="请输入账号" maxlength='100' style="width:350px"></el-input>
          </el-form-item>
          <el-form-item label="推广员：" prop="promoteName">
            <el-input v-model="editForm.promoteName" clearable placeholder="请输入推广员" maxlength='100' style="width:350px"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeEditDialog()">取 消</el-button>
        <el-button type="primary" @click="editPromotePost()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<style>
.input-with-select .el-input-group__prepend {
  background-color: #fff;
  width: 100px;
}
</style>

<script>
import {getSpendQrList, spendQrTotal, editSpendQr, editSpendQrPromote, queryGamesQr, queryFlGamesQr} from "@/api/system/details";
import {getToken} from "@/util/auth";
import {cloneObj, parseParam} from "@/util/util";
import VueElementLoading from 'vue-element-loading';
import roleDeatils from "@/views/role/deatils";
import {mapGetters} from "vuex";
export default {
  data() {
    return {
      colData : [
        { title: "打币时间", istrue: true },
        { title: "平台名称", istrue: true },
        { title: "玩家微信", istrue: false },
        { title: "区服", istrue: false },
        { title: "项目群", istrue: false },
        { title: "部门", istrue: true },
        { title: "推广员", istrue: true },

        { title: "游戏订单号", istrue: true },
        { title: "商户订单号", istrue: false },
        { title: "是否补单", istrue: false },
        { title: "备注", istrue: false },
        { title: "是否退款", istrue: false },
      ],
      checkedColumns :
        ["打币时间","平台名称"
          ,"部门","推广员","游戏订单号","是否补单"],
      checkBoxGroup :
        ["打币时间","平台名称","玩家微信","区服","项目群","部门","推广员","游戏订单号","商户订单号","是否补单","备注","是否退款"],
      isShowEdit:true,
      isShowPayTime:false,
      isshowtrue:false,
      dialogEditFormVisible:false,
      dialogFormVisible:false,
      mode:'',
      isActive: false,
      leading:true,
      input:'',
      select: '账号名称',
      row:{},
      page: {
        currentPage: 1,
        pageSize: 20,
        total: '',
      },
      time: null,
      timeDb: null,
      spendCount:{},
      formInline: {
        gameFlName:'',
        gameName:'',
        userAccount: '',
        payOrder:'',
        orderNum:'',
        isFirstPay:'',
        payWay:'',
        isReplenishment:'',
        isPayCurrency:'',
        promoteName:'',
        platformName:'',
        collectionAccount:'',
        program:'',
        department:'',
        isRefund:''
      },
      form: {
        payWay:'',
        orderNum:'',
        gameName:'',
        isFirstPay:2,
        isFirstPayS:'',
        discount:'',
        platformCurrency:'',
        platformName:'',
        playerWechat:'',
        serverNum:'',
        editPayTime:'',
        editPlatformCurrencyTime:'',
        memo:'',
        promoteName:'',
        collectionAccount:'',
        program:'',
        department:'',
        isRefund:'',
        isRefundS:'',
      },
      editForm:{
        userAccount:'',
        promoteName:''
      },
      gamelist:[],
      gameFllist:[],
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      tableData:[],
      rules: {
        userAccount:[
          {required: true, message: '请输入账号', trigger: 'blur'}
        ],
        promoteName:[
          {required: true, message: '请输入推广员', trigger: 'blur'}
        ],
      }
    };

  },
  watch: {
    checkedColumns(val) {
      let arr = this.checkBoxGroup.filter(i => !val.includes(i));
      this.colData.filter(i => {
        if (arr.indexOf(i.title) != -1) {
          i.istrue = false;
        } else {
          i.istrue = true;
        }
      });
    }
  },
  components: {
    VueElementLoading
  },
  computed: {
    ...mapGetters(["userInfo"]),
  },
  created() {
    if(this.userInfo.account != 'test999' && this.userInfo.account != 'test998') {
      this.isShowEdit = false
    }
    var startTime = undefined;
    var endTime = undefined;
    var startTimeDb = undefined;
    var endTimeDb = undefined;
    this.onload(startTime, endTime, startTimeDb, endTimeDb);
    this.loadGames()
  },
  methods: {
    loadGames() {
      queryFlGamesQr().then(res => {
        this.gameFllist = res.data.data
      })
      queryGamesQr().then(res => {
        this.gamelist = res.data.data
      })
    },
    suer() {
      if(this.form.isFirstPayS == '首充') {
        this.form.isFirstPay = 1
      } else if(this.form.isFirstPayS == '续充') {
        this.form.isFirstPay = 2
      } else if(this.form.isFirstPayS == '内充') {
        this.form.isFirstPay = 3
      } else if(this.form.isFirstPayS == 1) {
        this.form.isFirstPay = 1
      } else if(this.form.isFirstPayS == 2) {
        this.form.isFirstPay = 2
      } else if(this.form.isFirstPayS == 3) {
        this.form.isFirstPay = 3
      } else {
        this.form.isFirstPay = 2
      }
      if(this.form.isRefundS == '否') {
        this.form.isRefund = 1
      } else if(this.form.isRefundS == '是') {
        this.form.isRefund = 2
      } else if(this.form.isRefundS == 1) {
        this.form.isRefund = 1
      } else if(this.form.isRefundS == 2) {
        this.form.isRefund = 2
      }
      if(this.form.editPayTime != null && this.form.editPayTime.toString().indexOf("GMT") >= 0) {
        const y=this.form.editPayTime.getFullYear()
        const m=(this.form.editPayTime.getMonth()+1+'').padStart(2,'0')
        const d=(this.form.editPayTime.getDate()+'').padStart(2,'0')
        const hh=(this.form.editPayTime.getHours()+'').padStart(2,'0')
        const mm=(this.form.editPayTime.getMinutes()+'').padStart(2,'0')
        const ss=(this.form.editPayTime.getSeconds()+'').padStart(2,'0')
        var da =  `${y}-${m}-${d} ${hh}:${mm}:${ss}`
        this.form.editPayTime = da
      }
      if(this.form.editPlatformCurrencyTime != null && this.form.editPlatformCurrencyTime.toString().indexOf("GMT") >= 0) {
        const y=this.form.editPlatformCurrencyTime.getFullYear()
        const m=(this.form.editPlatformCurrencyTime.getMonth()+1+'').padStart(2,'0')
        const d=(this.form.editPlatformCurrencyTime.getDate()+'').padStart(2,'0')
        const hh=(this.form.editPlatformCurrencyTime.getHours()+'').padStart(2,'0')
        const mm=(this.form.editPlatformCurrencyTime.getMinutes()+'').padStart(2,'0')
        const ss=(this.form.editPlatformCurrencyTime.getSeconds()+'').padStart(2,'0')
        var da =  `${y}-${m}-${d} ${hh}:${mm}:${ss}`
        this.form.editPlatformCurrencyTime = da
      }
      editSpendQr(this.form).then(res => {
        if (res.data.success) {
          this.$message({
            type: "success",
            message: "更新成功!"
          });
          this.closeDialog()

          var startTime = undefined;
          var endTime = undefined;
          if (this.isNotEmpty(this.time)) {
            startTime = this.time[0].getTime()
            endTime = this.time[1].getTime()
          }
          var startTimeDb = undefined;
          var endTimeDb = undefined;
          if (this.isNotEmpty(this.timeDb)) {
            startTimeDb = this.timeDb[0].getTime()
            endTimeDb = this.timeDb[1].getTime()
          }
          this.onload(startTime, endTime, startTimeDb, endTimeDb);
        } else {
          this.$message({
            type: "error",
            message: res.data.msg
          });
        }
      });
    },
    async recover(row) {
      console.log(" this.row", row)
      this.dialogFormVisible = true;
      this.mode = '编辑 '+row.orderNum + ' 订单';
      //金额
      this.form.payAmount = row.payAmount
      this.form.orderNum = row.orderNum
      this.form.gameName = row.gameName
      if(row.isFirstPay > 0) {
        if(row.isFirstPay == 1) {
          this.form.isFirstPayS = '首充'
          this.form.isFirstPay = 1
        } else if(row.isFirstPay == 2) {
          this.form.isFirstPayS = '续充'
          this.form.isFirstPay = 2
        } else if(row.isFirstPay == 3)  {
          this.form.isFirstPayS = '内充'
          this.form.isFirstPay = 3
        }
      }
      if(row.isRefund > 0) {
        if(row.isRefund == 1) {
          this.form.isRefundS = '否'
          this.form.isRefund = 1
        } else if(row.isRefund == 2) {
          this.form.isRefundS = '是'
          this.form.isRefund = 2
        }
      }
      if(row.discount > 0) {
        this.form.discount = row.discount
      }
      if(row.platformCurrency > 0) {
        this.form.platformCurrency = row.platformCurrency
      }
      this.form.platformName = row.platformName
      this.form.playerWechat = row.playerWechat
      this.form.serverNum = row.serverNum
      this.form.memo = row.memo
      if(row.payWay=='TB' || row.payWay=='TB-P') {
        this.form.payWay = row.payWay
        this.form.editPayTime = new Date(row.payTime)
        this.isShowPayTime = true
      } else {
        this.form.editPayTime = null
        this.isShowPayTime = false
      }
      this.form.editPlatformCurrencyTime = new Date(row.platformCurrencyTime);
      this.form.promoteName = row.promoteName
      this.form.collectionAccount = row.collectionAccount
      this.form.program = row.program
      this.form.department = row.department
    },
    closeDialog() {
      this.dialogFormVisible = false
      this.form =  {
        orderNum:'',
        gameName:'',
        isFirstPay:2,
        discount:'',
        platformCurrency:'',
        platformName:'',
        playerWechat:'',
        serverNum:'',
        editPayTime:'',
        editPlatformCurrencyTime:'',
        memo:'',
        promoteName:'',
        collectionAccount:'',
        program:'',
        department:'',
        isRefund:'',
        isRefundS:'',
        isFirstPayS:''
      }
    },
    getSumDeposit() {
      let sums = [];
      sums[0] = '总计(小写)'
      sums[3] = this.spendCount.payAmountT
      sums[8] = this.spendCount.platformCurrencyT
      sums[10] = this.spendCount.welfareGiftT
      sums[11] = Number(this.spendCount.platformCurrencyT) + Number(this.spendCount.welfareGiftT)

      for(let i=0; i<=20; i++) {
        if(sums[i] === undefined) {
          sums[i] = '--'
        }
      }
      return sums;
    },
    handleExport() {
      this.$confirm("是否导出订单明细数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        var forming={};
        forming = cloneObj(this.formInline)
        if (this.isNotEmpty(this.time)) {
          forming.startTime = this.time[0].getTime()
          forming.endTime = this.time[1].getTime()
        }
        if (this.isNotEmpty(this.timeDb)) {
          forming.startTimeDb = this.timeDb[0].getTime()
          forming.endTimeDb = this.timeDb[1].getTime()
        }
        window.location.href = `/api/blade-details/spend/export-spendqr?blade-auth=${getToken()}&${parseParam(forming)}`;

      });
    },
    closeEditDialog() {
      this.dialogEditFormVisible = false
      this.editForm = {
          userAccount:'',
          promoteName:''
      }
    },
    editPromote(){
      this.dialogEditFormVisible = true
      this.mode = '批量修改推广员';
    },
    editPromotePost(){
      editSpendQrPromote(this.editForm).then(res => {
        if (res.data.success) {
          this.$message({
            type: "success",
            message: "更新成功!"
          });
          this.closeEditDialog()

          var startTime = undefined;
          var endTime = undefined;
          if (this.isNotEmpty(this.time)) {
            startTime = this.time[0].getTime()
            endTime = this.time[1].getTime()
          }
          var startTimeDb = undefined;
          var endTimeDb = undefined;
          if (this.isNotEmpty(this.timeDb)) {
            startTimeDb = this.timeDb[0].getTime()
            endTimeDb = this.timeDb[1].getTime()
          }
          this.onload(startTime, endTime, startTimeDb, endTimeDb);
        } else {
          this.$message({
            type: "error",
            message: res.data.msg
          });
        }
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.page.pageSize = val;
      var startTime = undefined;
      var endTime = undefined;
      if (this.isNotEmpty(this.time)) {
        startTime = this.time[0].getTime()
        endTime = this.time[1].getTime()
      }
      var startTimeDb = undefined;
      var endTimeDb = undefined;
      if (this.isNotEmpty(this.timeDb)) {
        startTimeDb = this.timeDb[0].getTime()
        endTimeDb = this.timeDb[1].getTime()
      }
      this.onload(startTime, endTime, startTimeDb, endTimeDb);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.page.currentPage = val;
      var startTime = undefined;
      var endTime = undefined;
      if (this.isNotEmpty(this.time)) {
        startTime = this.time[0].getTime()
        endTime = this.time[1].getTime()
      }
      var startTimeDb = undefined;
      var endTimeDb = undefined;
      if (this.isNotEmpty(this.timeDb)) {
        startTimeDb = this.timeDb[0].getTime()
        endTimeDb = this.timeDb[1].getTime()
      }
      this.onload(startTime, endTime, startTimeDb, endTimeDb);
    },
    isNotEmpty(arr) {
      return arr != null && arr.length !== 0
    },
    onSubmit() {
      var startTime = undefined;
      var endTime = undefined;
      var startTimeDb = undefined;
      var endTimeDb = undefined;
      this.page.currentPage=1
      this.onload(startTime, endTime, startTimeDb, endTimeDb);
    },

    onload(startTime,endTime, startTimeDb, endTimeDb){

      if(this.isNotEmpty(this.time)) {
        startTime = this.time[0].getTime()
        endTime = this.time[1].getTime()
      }
      if(this.isNotEmpty(this.timeDb)) {
        startTimeDb = this.timeDb[0].getTime()
        endTimeDb = this.timeDb[1].getTime()
      }

      this.isActive = true;
      getSpendQrList(this.page.currentPage, this.page.pageSize, Object.assign(this.formInline), startTime,endTime,startTimeDb,endTimeDb).then(res => {
        this.isActive = false;
        const data = res.data.data;
        console.log("res.data.data", res.data.data)
        this.page.total = data.total;
        this.tableData = data.records;
        this.loading = false;
        spendQrTotal(Object.assign(this.formInline), startTime,endTime,startTimeDb,endTimeDb).then(res => {
          this.isActive = false;
          console.log("res",res)
          const data = res.data.data;
          this.spendCount = data
        });
      });

    },
  }
}

</script>

<style>
.customViewUser1{
  width: 30%;
  background-color: #FFFFFF !important;
}
</style>
